<?php
    $pubpid = "12454454";
	// Database configuration
    $db_server   = 'localhost';
    $db_name     = 'saludaun_bolivar';
    $db_username = 'saludaun_dpoveda';
    $db_password = 's0t0c0c';  

	$dbconnection = @mysql_connect($db_server,$db_username,$db_password) or die("Error conectando a la BBDD<br/><br/>");

	//echo "Conectado correctamente<br/><br/>";

	$db = mysql_select_db($db_name, $dbconnection) or die ($dbname . " Base de datos no encontrada.<br/><br/>"); 
	
    //echo "Base de datos " . $db_name . " seleccionada<br/><br/>";
		
	$result = mysql_query("SELECT * from patient_data where pubpid='$pubpid'") or die('Could not query');
        //$json = array();

	$total_records = mysql_num_rows($result);

	if($total_records >= 1){
          
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
					   
            $pid = $row['pid'];
            
            require_once("ccr/createCCR.php");
			
            $return_value = createCCR('generate',$pid,'yes');
            
            return array('Success' => $return_value);         
	}
    mysql_close($dbconnection);
?>